﻿using System.Data.Entity;
using Silent.MDB.Common.Data;
using Silent.MDB.Server.Model.Contexts.Configurations.Entities;

namespace Silent.MDB.Server.Model.Contexts
{
    public class DefaultDbContext : DbContext, IDataContext
    {
        public DefaultDbContext()
        {
        }
        public DefaultDbContext(string connectionString)
            : base(connectionString)
        {
        }

        public IDbSet<RootObject> RootObjects
        {
            get { return Set<RootObject>(); }
        }
        public IDbSet<Folder> Folders
        {
            get { return Set<Folder>(); }
        }
        public IDbSet<Person> Persons
        {
            get { return Set<Person>(); }
        }
        public IDbSet<Teacher> Teachers
        {
            get { return Set<Teacher>(); }
        }
        public IDbSet<Student> Students
        {
            get { return Set<Student>(); }
        }
        public IDbSet<Department> Departments
        {
            get { return Set<Department>(); }
        }
        public IDbSet<Cathedra> Cathedras
        {
            get { return Set<Cathedra>(); }
        }
        public IDbSet<Faculty> Faculties
        {
            get { return Set<Faculty>(); }
        } 

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            EntityConfigurationFactory.CreateConfigurations(modelBuilder);
        }
    }
}
